import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)



export const routes = [
    // 路由重定向
    {
        path: '/', redirect: '/login',

        meta: {
            hidden: true,
            title: '主页面'
        },
    },
    // 登陆
    {
        path: '/login',
        meta: {
            hidden: true,
            title: '登陆页面'
        },
        component: () => import('../page/login/login'),
    },
    // 首页
    {
        path: '/index',
        meta: {
            hidden: true,
            title: '首页'
        },
        component: () => import('../page/index')
    },
    //show 页面
    {
        path: '/show',
        meta: {
            hidden: true,
            title: 'show',

        },
        component: () => import('../page/index'),
        children: [
            {
                path: 'index',
                meta: {

                    title: '系统首页',
                },
                component: () => import('../page/show/show')
            },]
    },

    // city菜单
    {
        path: '/city',
        meta: {
            title: '城市菜单',
            icon: "el-icon-c-scale-to-original"

        },
        component: () => import('../page/index'),
        children: [
            {
                path: 'add',
                // name:'添加城市',
                meta: {

                    title: '添加城市',
                    icon: "el-icon-document-add"
                },
                component: () => import('../page/city/add')
            },
            {
                path: 'list',
                meta: {
                    title: '城市列表',
                    icon: "el-icon-reading"
                },
                component: () => import('../page/city/list')
            },
            {
                path: 'edit',
                name:'编辑城市',
                meta: {
                    hidden: true,
                    title: '编辑城市',
                    icon: "el-icon-reading"
                },
                component: () => import('../page/city/add')
            },

        ]
    }
    // area菜单
    , {
        path: '/area',
        meta: {
            title: '区域菜单',
            icon: "el-icon-s-grid"
        },
        component: () => import('../page/index'),
        children: [
            {
                path: 'add',
                meta: {
                    title: '区域添加',
                    icon: "el-icon-add-location"
                },
                component: () => import('../page/area/add')
            },
            {
                path: 'list',
                meta: {
                    title: '区域列表',
                    icon: "el-icon-map-location"
                },
                component: () => import('../page/area/list')
            },
            {
                path: 'edit',
                name:'区域编辑',
                meta: {
                    title: '区域编辑',
                    hidden: true,
                    icon: "el-icon-add-location"
                },
                component: () => import('../page/area/add')
            },


        ]
    },
    // 影院菜单
    {
        path: '/cinema',
        meta: {
            title: '影院菜单',
            icon: "el-icon-video-camera-solid"
        },
        component: () => import('../page/index'),
        children: [
            {
                path: 'add',
                meta: {
                    title: '影院添加',
                    icon: "el-icon-s-order"
                },
                component: () => import('../page/cinema/add')
            },
            {
                path: 'list',
                meta: {
                    title: '影院列表',
                    icon: "el-icon-s-unfold"
                },
                component: () => import('../page/cinema/list')
            },
            {
                path: 'adit',
                name:'影院编辑',
                meta: {
                    title: '影院编辑',
                    hidden: true,
                    icon: "el-icon-s-order"
                },
                component: () => import('../page/cinema/add')
            },
        ]
    },
    // 影片菜单
    {
        path: '/film',
        meta: {
            title: '影片菜单',
            icon: "el-icon-pie-chart"
        },
        component: () => import('../page/index'),
        children: [
            {
                path: 'add',
                meta: {
                    title: '影片添加',
                    icon: "el-icon-document-checked"
                },
                component: () => import('../page/film/add')
            },
            {
                path: 'list',
                meta: {
                    title: '影片列表',
                    icon: "el-icon-document"
                },
                component: () => import('../page/film/list')
            },
            {
                path: 'adit',
                name:'影片编辑',
                meta: {
                    title: '影片编辑',
                    hidden: true,
                    icon: "el-icon-document-checked"
                },
                component: () => import('../page/film/add')
            }
        ]
    },
    // demo菜单
    {
        path: '/demo',
        meta: {
            title: 'demo菜单',
            icon: "el-icon-pie-chart",
            hidden:true,
        },
        component: () => import('../page/demo'),
        // children: [
        //     {
        //         path: 'add',
        //         meta: {
        //             title: '影片添加',
        //             icon: "el-icon-document-checked"
        //         },
        //         component: () => import('../page/film/add')
        //     },
        //     {
        //         path: 'list',
        //         meta: {
        //             title: '影片列表',
        //             icon: "el-icon-document"
        //         },
        //         component: () => import('../page/film/list')
        //     },
        // ]
    },

]

let router = new Router({
    routes,
})
import stroe from '../vuex/store'
let islogin = stroe.state.islogin
router.beforeEach((to, from, next) => {
    // 修改网页标题
    document.title = to.meta.title;
    if (!islogin && to.path !== '/login') {
        next('/login');
    } else {
        next();
    }
})
export default router

